
package com.ami.kvm.jviewer.gui;

import java.awt.Dimension;
import java.util.TimerTask;

import com.ami.iusb.FloppyRedir;
import com.ami.kvm.jviewer.Debug;
import com.ami.kvm.jviewer.common.ISOCFrameHdr;

public class FrameRateTask extends TimerTask {
	private static final int FETCH_RES_DELAY = 3;
	Dimension Client_System_prev;
	Dimension Client_System;
	boolean updateLEDStatus = false;
	boolean syncLEDFromClient = false;
	byte ledStatus = 0;
	int resWait = 0;

	public void run() {
		if (this.resWait > 0)
			this.resWait -= 1;
		try {// tianlin fps 获取
			JViewerApp.getInstance().setAppWndLabel(JViewerApp.getInstance().getVidClnt().getM_frameRate() + " fps");
			JViewerApp.getInstance().getVidClnt().setM_frameRate(0);
		} catch (Exception localException1) {
			Debug.out.println(localException1);
		}

		ISOCFrameHdr localISOCFrameHdr = JViewerApp.getInstance().getSocframeHdr();

		if (this.resWait == 0) {
			this.Client_System = JViewerApp.getInstance().getCurrentMonitorResolution();
			this.resWait = 3;
		}

		if (this.Client_System_prev == null) {
			this.Client_System_prev = this.Client_System;
		}
		if ((this.Client_System.width != this.Client_System_prev.width)
				|| (this.Client_System.height != this.Client_System_prev.height)) {
			JViewerApp.getInstance().getVidClnt().setFullScreenMode();

			JViewerApp.getInstance().getVidClnt().setZoomOptionStatus();
		}
		this.Client_System_prev = this.Client_System;

		if (this.updateLEDStatus) {
			FloppyRedir localFloppyRedir = new FloppyRedir(true);
			try {
				localFloppyRedir.setKeyboardLEDStatus(this.ledStatus);
			} catch (Exception localException2) {
				Debug.out.println(localException2);
			} finally {
				localFloppyRedir = null;
			}
		}

		this.updateLEDStatus = false;
		if (this.syncLEDFromClient) {
			JViewerApp.getInstance().sendClientLEDStatus();
			this.syncLEDFromClient = false;
		}
	}

	public void updateKeyboardLEDStatus(byte paramByte) {
		this.updateLEDStatus = true;
		this.ledStatus = paramByte;
	}

	public boolean isSyncLEDFromClient() {
		return this.syncLEDFromClient;
	}

	public void setSyncLEDFromClient(boolean paramBoolean) {
		this.syncLEDFromClient = paramBoolean;
	}
}
